import request from '@/utils/request';

export async function uploadMinio(file: File): Promise<{
  data?: { fileUrl: string };
  error?: Error;
}> {
  try {
    const formData = new FormData();
    formData.append('file', file);
    const response = await request('/infrastructure/uploadMinio', {
      method: 'POST',
      data: formData,
      headers: {
        'Content-Type': 'multipart/form-data',
        token: localStorage.getItem('token') || '',
      },
    });
    return { data: response.data };
  } catch (error) {
    return { error: error as Error };
  }
}